

let sportOrederTableObserver = null
import { createorder } from '@/content-scripts/components/order/index'

export function sportOrederTopSearch() {
    if (sportOrederTableObserver) sportOrederTableObserver.disconnect();

    let previousValues = {
        typeValue: null,
        directionValue: null,
        tradingPairsValue: null
    }

    sportOrederTableObserver = new MutationObserver(() => {
        const searchSearchList = document.querySelectorAll(
            ".mantine-7vse74 > .mantine-1tz5yee > div > .mantine-dcm9q0 > input"
        );
        const typeSearch = searchSearchList[0]
        const directionSearch = searchSearchList[1]
        const tradingPairsSearch = searchSearchList[2]
        const hasChange =
            typeSearch.value !== previousValues.typeValue ||
            directionSearch.value !== previousValues.directionValue ||
            tradingPairsSearch.value !== previousValues.tradingPairsValue
        if (typeSearch && directionSearch && tradingPairsSearch && hasChange) {
            previousValues = {
                typeValue: typeSearch.value,
                directionValue: directionSearch.value,
                tradingPairsValue: tradingPairsSearch.value
            }
            console.log(previousValues, 'sportOrederTopSearch previousValues');
            createorder(previousValues)
        }

    });
    // console.log(perpetualTableTabsObserver,1312313)
    sportOrederTableObserver.observe(document.body, {
        childList: true,
        subtree: true,
        attributes: true,
        characterData: true,
    });
}

import { createhistoryorder } from "@/content-scripts/components/order/history";

export function sportOrederHistoryTopSearch() {
    if (sportOrederTableObserver) sportOrederTableObserver.disconnect();

    let previousValues = {
        typeValue: null,
        directionValue: null,
        tradingPairsValue: null,
        startTimeValue: null,
        endTimeValue: null
    }

    sportOrederTableObserver = new MutationObserver(() => {
        const searchSearchList = document.querySelectorAll(
            ".mantine-7vse74 > .mantine-1tz5yee > div > .mantine-dcm9q0 > input"
        );

        const searchTimeList = document.querySelectorAll('.mantine-25vsaa > .mantine-qkftat > input')
        // console.log(searchSearchList,SearchTimeList, 'seeeeeehistory');

        const typeSearch = searchSearchList[0]
        const directionSearch = searchSearchList[1]
        const tradingPairsSearch = searchSearchList[2]
        const startTimeSearch = searchTimeList[0]
        const endTimeSearch = searchTimeList[1]
        const hasChange =
            typeSearch.value !== previousValues.typeValue ||
            directionSearch.value !== previousValues.directionValue ||
            tradingPairsSearch.value !== previousValues.tradingPairsValue ||
            startTimeSearch.value !== previousValues.startTimeValue ||
            endTimeSearch.value !== previousValues.endTimeValue
        if (typeSearch && directionSearch && tradingPairsSearch && startTimeSearch && endTimeSearch && hasChange) {
            previousValues = {
                typeValue: typeSearch.value,
                directionValue: directionSearch.value,
                tradingPairsValue: tradingPairsSearch.value,
                startTimeValue: startTimeSearch.value,
                endTimeValue: endTimeSearch.value
            }
            console.log(previousValues, 'sportOrederTopSearch previousValues');
            if (previousValues.startTimeValue && previousValues.endTimeValue) {
                createhistoryorder(previousValues)
            }

        }

    });
    // console.log(perpetualTableTabsObserver,1312313)
    sportOrederTableObserver.observe(document.body, {
        childList: true,
        subtree: true,
        attributes: true,
        characterData: true,
    });
}

import { creatrecordeorder } from "@/content-scripts/components/order/record";

export function sportOrederRecordTopSearch() {
    if (sportOrederTableObserver) sportOrederTableObserver.disconnect();

    let previousValues = {
        currentValue: null,
        startTimeValue: null,
        endTimeValue: null
    }

    sportOrederTableObserver = new MutationObserver(() => {
        const searchSearchList = document.querySelectorAll(
            ".mantine-7vse74 > .mantine-1tz5yee > div > .mantine-dcm9q0 > input"
        );

        const searchTimeList = document.querySelectorAll('.mantine-25vsaa > .mantine-qkftat > input')
        // console.log(searchSearchList,SearchTimeList, 'seeeeeehistory');
        // console.log(searchSearchList, searchTimeList, 'sportOrederRecordTopSearch sportOrederRecordTopSearch');

        const currenySearch = searchSearchList[0]
        const startTimeSearch = searchTimeList[0]
        const endTimeSearch = searchTimeList[1]
        const hasChange =
            currenySearch.value !== previousValues.currentValue ||
            startTimeSearch.value !== previousValues.startTimeValue ||
            endTimeSearch.value !== previousValues.endTimeValue
        if (currenySearch && startTimeSearch && endTimeSearch && hasChange) {
            previousValues = {
                currentValue: currenySearch.value,
                startTimeValue: startTimeSearch.value,
                endTimeValue: endTimeSearch.value
            }
            console.log(previousValues, 'sportOrederTopSearch previousValues');
            if (previousValues.startTimeValue && previousValues.endTimeValue) {
                creatrecordeorder(previousValues)
            }

        }

    });
    // console.log(perpetualTableTabsObserver,1312313)
    sportOrederTableObserver.observe(document.body, {
        childList: true,
        subtree: true,
        attributes: true,
        characterData: true,
    });
}


